home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / Button / Sources / Environs.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  1.4 KB  |  53 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Environs.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Author:                Greg Friedman
  7. //
  8. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef ENVIRONS_H
  13. #include "Environs.h"
  14. #endif
  15.  
  16. #ifndef __GESTALT__
  17. #include <Gestalt.h>
  18. #endif
  19.  
  20. #ifndef __OSA__
  21. #include <OSA.h>
  22. #endif
  23.  
  24. //----------------------------------------------------------------------------------------
  25. //    HasGestaltAttribute
  26. //----------------------------------------------------------------------------------------
  27.  
  28. FW_Boolean HasGestaltAttribute(OSType itsAttr, short itsBit)
  29. {
  30.     long response;
  31.     return (Gestalt(itsAttr, &response) == noErr) && (((response >> itsBit) & 1) != 0);
  32. }
  33.  
  34. //----------------------------------------------------------------------------------------
  35. //    HasAppleScript
  36. //----------------------------------------------------------------------------------------
  37.  
  38. FW_Boolean HasAppleScript()
  39. {
  40.     static FW_Boolean checked = FALSE;
  41.     static FW_Boolean hasFeature = FALSE;
  42.     
  43.     if (!checked)
  44.     {
  45.         hasFeature = HasGestaltAttribute(gestaltAppleEventsAttr, gestaltScriptingSupport);
  46.         hasFeature &= ((Ptr)OSALoad != (Ptr)kUnresolvedCFragSymbolAddress);
  47.         checked = TRUE;
  48.     }
  49.     
  50.     return hasFeature;
  51. }
  52.  
  53.